#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e5+10;
int T,cmplt;
int n,m,L,V;
int d[N],v[N],a[N];
int pre_sum[N];
int plc[N];
int state[30];
inline int Find(int x)
{
    int l=1,r=m,mid,ret;
    while(l<=r)
    {
        mid=l+r>>1;
        if(plc[mid]>=x)ret=mid,r=mid-1;
        else l=mid+1;
    }
    return ret;
}
inline int FinD(int x)
{
    int l=1,r=m,mid,ret;
    while(l<=r)
    {
        mid=l+r>>1;
        if(plc[mid]<=x)ret=mid,l=mid+1;
        else r=mid-1;
    }
    return ret;
}
inline bool check(int stt)
{
    int ret=0;
    for(int i=1;i<=m;i++)
        if((1<<(i-1))&stt)ret|=state[i];
    return ret==cmplt;
}
inline int cnt(int stt)
{
    int ret=0;
    while(stt)
    {
        ret++;
        stt-=stt&-stt;
    }
    return ret;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--)
    {
        memset(state,0,sizeof state);
        scanf("%d%d%d%d",&n,&m,&L,&V);
        for(int i=1;i<=n;i++)scanf("%d%d%d",&d[i],&v[i],&a[i]);
        for(int i=1;i<=m;i++)scanf("%d",&plc[i]);
        sort(plc+1,plc+m+1);
        int ff;
        if(a[1]==0)ff=0;
        if(a[1]<0)ff=-1;
        if(a[1]>0)ff=1;
        if(m<=20)
        {
            int ans1=0;
            for(int i=1;i<=n;i++)
            {
                if(d[i]>plc[m])continue;
                if(a[i]==0)
                {
                    if(v[i]>V)
                    {
                        ans1++;
                        for(int j=Find(d[i]);j<=m;j++)state[j]|=(1<<(i-1));
                    }
                }
                else
                {
                    double x=(double)(V*V-v[i]*v[i])/2.0/(double)a[i];
                    if(v[i]<=V)//st_speed<=V
                    {
                        if(a[i]<=0)continue;//unable to be faster
                        if((double)d[i]+x>=(double)plc[m])continue;//when it's fast enough,the car is already out of the area
                        else
                        {
                            ans1++;
                            int t=x+1;
                            for(int j=Find(d[i]+t);j<=m;j++)state[j]|=(1<<(i-1));
                        }
                    }
                    else//st_speed>V
                    {
                        if(a[i]>=0)
                        {
                            ans1++;
                            for(int j=Find(d[i]);j<=m;j++)state[j]|=(1<<(i-1));
                            continue;
                        }
                        int t=(x+1e-10);
                        if((double)d[i]+x>(double)plc[m])//when it's slow enough,the car is already out of the area
                        {
                            ans1++;
                            for(int j=Find(d[i]);j<=m;j++)state[j]|=(1<<(i-1));
                            continue;
                        }
                        else if(d[i]+t==plc[m])
                        {
                            ans1++;
                            for(int j=Find(d[i]);j<m;j++)state[j]|=(1<<(i-1));
                            continue;
                        }
                        else
                        {
                            if(plc[FinD(d[i]+t)]>=d[i])
                            {
                                ans1++;
                                for(int j=Find(d[i]);j<=FinD(d[i]+t);j++)state[j]|=(1<<(i-1));
                            }
                        }
                    }
                }
            }
            cmplt=0;
            int ans=m;
            for(int j=1;j<=m;j++)cmplt|=state[j];
            for(int stt=0;stt<(1<<m);stt++)
                if(check(stt))ans=min(ans,cnt(stt));
            printf("%d %d\n",ans1,m-ans);
        }
        else if(ff>=0)
        {
            int ans1=0;
            for(int i=1;i<=n;i++)
            {
                if(d[i]>plc[m])continue;
                if(a[i]==0)
                {
                    if(v[i]>V)ans1++,pre_sum[Find(d[i])]++;
                }
                else
                {
                    double x=(double)(V*V-v[i]*v[i])/2.0/(double)a[i];
                    if(v[i]<=V)//st_speed<=V
                    {
                        if(a[i]<=0)continue;//unable to be faster
                        if((double)d[i]+x>=(double)plc[m])continue;//when it's fast enough,the car is already out of the area
                        else
                        {
                            ans1++;
                            int t=x+1;
                            pre_sum[Find(d[i]+t)]++;
                        }
                    }
                    else//st_speed>V
                    {
                        if(a[i]>=0){ans1++,pre_sum[Find(d[i])]++;continue;}//when it's slow enough,the car is already out of the area
                        if((double)d[i]+x>(double)plc[m]){ans1++,pre_sum[Find(d[i])]++;continue;}
                        else
                        {
                            int t=(x+1e-10);
                            if(Find(d[i])!=FinD(d[i]+t)+1)ans1++;
                            pre_sum[Find(d[i])]++;
                            pre_sum[FinD(d[i]+t)+1]--;
                        }
                    }
                }
            }
            int ans2;
            if(ans1==0)ans2=m;
            else
            {
                if(m==1)ans2=1;
                else ans2=m-1;
            }
            printf("%d %d\n",ans1,ans2);
        }
    }
}
